			<script type="text/javascript"
			  src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBXjLdTmaYkzOIa-uIHnlWCCEm2MCCiMPg&sensor=true">
			</script>
			
			<script>
				var rphIconBase = '<?= base_url().'img/misc/'; ?>';
				
				function initialize(){
					var mapProp = {
						center: new google.maps.LatLng(-7.28755, 112.733),
						zoom: 9,
						mapTypeId: google.maps.MapTypeId.ROADMAP
					};
					var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
					allMaps.push(map);
					<?php
						if($all_rph != null){
							foreach($all_rph as $titik){
								echo "var marker".$titik['ID_TITIK_PASOK']." = new google.maps.Marker();";
								echo "marker".$titik['ID_TITIK_PASOK'].".setPosition(new google.maps.LatLng(".$titik['LAT'].", ".$titik['LON']."));";
								echo "marker".$titik['ID_TITIK_PASOK'].".setMap(map);";
								echo "marker".$titik['ID_TITIK_PASOK'].".setIcon(rphIconBase + 'rph.png');";
								
								echo "var content".$titik['ID_TITIK_PASOK']." = 'Nama: ".$titik['NAMA']." <br>Alamat: ".$titik['ALAMAT']." <br>Rata produksi: ".$titik['JUMLAH_PEMOTONGAN_PER_HARI']."';";
								echo "var infoWindow".$titik['ID_TITIK_PASOK']." = new google.maps.InfoWindow({content: content".$titik['ID_TITIK_PASOK']."});";
								
								echo "onSpotClicked(marker".$titik['ID_TITIK_PASOK'].", content".$titik['ID_TITIK_PASOK'].", infoWindow".$titik['ID_TITIK_PASOK'].", map);";
								
								echo "allMarkers.push(marker".$titik['ID_TITIK_PASOK'].");";
							}
						}
					
					?>
					
				}
				
				function onSpotClicked(marker, content, infowindow, map){
					google.maps.event.addListener(marker, "mouseover", function () {
						infowindow.setContent(content);
						infowindow.open(map,this);
					});
					
					google.maps.event.addListener(marker, "mouseout", function () {
						infowindow.close();
					});
				}
				var allMarkers = [];
				function initialize2(){
					var mapProp = {
						center: new google.maps.LatLng(-7.28755, 112.733),
						zoom: 9,
						mapTypeId: google.maps.MapTypeId.ROADMAP
					};
					var map = new google.maps.Map(document.getElementById("googleMap2"),mapProp);
					allMaps.push(map);			
					google.maps.event.addListener(map, 'click', 
						function(e) {
							if(markers[0] == null){
								placeMarker(e.latLng, map);
							} else {
								markers[0].setPosition(e.latLng);
								markers[0].setMap(map);
							}
									
							$('#lat').val(e.latLng.lat());
							$('#lng').val(e.latLng.lng());
						});		
				}
				
				function placeMarker(position, map) {
					var marker = new google.maps.Marker({
						position: position,
						map: map
					});
					map.panTo(position);
					marker.setIcon(rphIconBase + 'rph.png');
					markers.push(marker);
					map.setCenter(marker.getPosition());
				}
				
				function deleteRph(idPasok){
					$.ajax({
						url: "<?= base_url(); ?>rph/delete_rph",
						type: "POST",
						data: "id_titik_pasok="+idPasok,
						success: function(msg){
							if(msg=="true") window.location = "<?= base_url(); ?>rph";
						}
					});
				}
				
				function updateRph(id){
					$('body').animate({scrollTop:410});
					$('#rph-title').html("Ubah Data RPH");					
					$('#nama').val($(".nama"+id).html());
					$('#alamat').val($(".alamat"+id).html());
					$('#id_kota').val($(".id_kota"+id).html());
					$('#no_telp').val($(".no_telp"+id).html());
					$('#email').val($(".email"+id).html());
					$('#kode_pos').val($(".kode_pos"+id).html());
					$('#tanggal_berdiri').val($(".tanggal_berdiri"+id).html());
					$('#produksi_normal').val($(".pemotongan"+id).html());
					$('#info').val($(".info"+id).html());
					$('#lat').val($(".lat"+id).val());
					$('#lng').val($(".lng"+id).val());
					$('#jumlah_dokter_hewan').val($(".dokter"+id).val());
					$('#lisensi').val($(".lisensi"+id).val());
					$('#jumlah_juru_sembelih').val($(".juru"+id).val());
					$('#jumlah_keurmaster').val($(".keurmaster"+id).val());
					$('#rph-form').attr("action","<?php echo base_url()?>rph/update_rph");
					$('#id-rph').val(id);
					if(markers[0] == null){
						placeMarker(new google.maps.LatLng($('#lat').val(), $('#lng').val()), allMaps[1]);
					} else {
						markers[0].setPosition(new google.maps.LatLng($('#lat').val(), $('#lng').val()));
						markers[0].setMap(allMaps[1]);
						allMaps[1].setCenter(markers[0].getPosition());
					}
				}
				
				var markers = [];
				var allMaps = [];
				google.maps.event.addDomListener(window, 'load', initialize);
				google.maps.event.addDomListener(window, 'load', initialize2);
				
				function resetForm(){
					$('#rph-title').html("Menambahkan Data RPH");
					$('#rph-form').attr("action","<?php echo base_url(); ?>rph/add_rph");
					$('#id-rph').val("");
					$('#lat').val("");
					$('#lng').val("");
					markers[0].setMap(null);
				}
			</script>
			
			<div id="titik-jual-edit">
				<?php $this->load->view('rph/rph_edit', array('NEW' => TRUE)); ?>
			</div></div></div>
			
			<div id="titik-jual-list">
				<div class="row-fluid sortable">		
					<div class="box span12">
						<div class="box-header well" data-original-title>
							<h2><i class="icon-home"></i> Rumah Pemotongan Hewan</h2>
							<div class="box-icon">
								<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
							</div>
						</div>
						<div class="box-content">
							<table class="table table-striped table-bordered bootstrap-datatable datatable">
							  <thead>
								  <tr>
									  <th>Nama</th>
									  <th>Alamat</th>
									  <th>Kota</th>
									  <th>No Telp</th>
									  <th>Email</th>
									  <th>Kode Pos</th>
									  <th>Tanggal Berdiri</th>
									  <th>Penjualan Normal</th>
									  <th>Info</th>
									  <th style="width:77px;!important">Action</th>
								  </tr>
							  </thead>   
							  <tbody>
								<?php $this->load->view('rph/rph_list'); ?>
							</tbody>
						  </table>            
						</div>
					</div><!--/span-->
			
				</div><!--/row-->
			</div>
			